{% extends "oj_base.html" %}
{% block title %}
    比赛列表
{% endblock %}
{% block body %}
    {% load contest %}
    <div class="container main">
        <div class="row">
            <div class="col-md-9 col-lg-9">
                <div class="row">
                    <div class="right">
                        <form class="form-inline" method="get">
                            <div class="form-group-sm">
                                <input name="keyword" class="form-control" value="{{ keyword }}" placeholder="请输入关键词">
                                <input type="submit" value="搜索" class="btn btn-primary">
                            </div>
                        </form>
                    </div>
                </div>
                <div>
                    {% if contests %}
                    <table class="table table-striped">
                        <thead>
                        <tr>
                            <th>#</th>
                            <th>比赛名称</th>
                            <th>开始时间</th>
                            <th>比赛类型</th>
                            <th>状态</th>
                        </tr>
                        </thead>
                        <tbody>
                        {% for item in contests %}
                            <tr>
                                <th scope="row"><a href="/contest/{{ item.id }}/">{{ item.id }}</a></th>
                                <td><a href="/contest/{{ item.id }}/">{{ item.title }}</a></td>
                                <td>{{ item.start_time }}</td>

                                {% ifequal item.contest_type 0 %}
                                    <td>私有小组赛</td>
                                {% endifequal %}
                                {% ifequal item.contest_type 1 %}
                                    <td>公开赛</td>
                                {% endifequal %}
                                {% ifequal item.contest_type 2 %}
                                    <td>公开赛(密码保护)</td>
                                {% endifequal %}
                                {% ifequal item.contest_type 3 %}
                                    <td>小组邀请赛</td>
                                {% endifequal %}

                                <td class="{{ item|contest_status_color }}">{{ item|contest_status }}</td>
                            </tr>
                        {% endfor %}
                        </tbody>
                    </table>
                    {% if request.user.is_authenticated  %}
                    {% include "oj/contest/_contest_filter.html" %}
                    {% endif %}
                    <nav>
                        <ul class="pager">
                            {% if previous_page %}
                                <li class="previous">
                                       <a href="/contests/{{ previous_page }}/{% if keyword %}?keyword={{ keyword }}{% endif %}{% if join %}?join={{ join }}{% endif %}">
                                    <span aria-hidden="true">&larr;</span> 上一页</a></li>
                            {% endif %}
                            {% if next_page %}
                                <li class="next">
                                       <a href="/contests/{{ next_page }}/{% if keyword %}?keyword={{ keyword }}{% endif %}{% if join %}?join={{ join }}{% endif %}">下一页 <span
                                        aria-hidden="true">&rarr;</span></a></li>
                            {% endif %}
                        </ul>
                    </nav>
                    {% else %}
                        <p>当前没有合适的比赛,你可以尝试到<a href="/groups/">小组列表</a>申请加入一些小组,以便参加小组内部的比赛</p>
                        {% include "oj/contest/_contest_filter.html" %}
                    {% endif %}
                </div>
            </div>

            <div class="col-md-3 col-lg-3">
                {% include "oj/announcement/_announcement_panel.html" %}
            </div>
        </div>
    </div>
{% endblock %}


{% block js_block %}
{% endblock %}